<template>
	<view class="news-detail">
		<view class="title">
			{{newsDetail.title}}
		</view>
		<view class="time">
			<text>发表时间：{{newsDetail.add_time | dataFormat()}}</text>
			<text>浏览次数：{{newsDetail.click}}</text>
		</view>
		<view class="content">
			<!-- 富文本 -->
			<rich-text :nodes="newsDetail.content"></rich-text>
		</view>
	</view>
</template>

<script>
	import { reqNewsDetail } from '@/api'
	export default {
		data() {
			return {
				id: '', // 商品详情id
				newsDetail: {}
			};
		},
		onLoad(options) {
			this.id = options.id
			this.getNewsDetail(this.id)
		},
		methods:{
			async getNewsDetail(pid) {
				const result = await reqNewsDetail(pid)
				if(result.code === 200) {
					this.newsDetail = result.data
				} else {
					uni.showToast({
						title:'获取资讯失败！'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.news-detail {
		padding: 15rpx;
		.title {
			font-size: 36rpx;
			font-weight: bold;
			text-align: center;
		}
		.time {
			display: flex;
			justify-content: space-between;
			margin-top: 10rpx;
			font-size: 28rpx;
		}
		.content {
			margin-top: 30rpx;
		}
	}
</style>
